package com.fatgirl.patterns.iterator
{

	/**
	 *  
	 * 数组迭代器
	 * 次数组迭代器只适用于索引数组
	 * 关联数组不适合
	 * 
	 * @author iceman
	 * 
	 */
	public class ArrayIterator implements IIterator
	{
		private var m_collection:Array;
		private var m_index:uint;
		public function ArrayIterator(_arr:Array)
		{
			m_collection = _arr;
			m_index = 0;
		}
		
		/**
		 * 重置 
		 * 
		 */
		public function reset():void
		{
			m_index = 0;
		}
		
		/**
		 * 下个元素，若为第一次调用 返回0索引 
		 * @return 
		 * 
		 */
		public function next():Object
		{
			return m_collection[m_index++];
		}
		
		/**
		 * 是否存在下个元素 
		 * @return 
		 * 
		 */
		public function hasNext():Boolean
		{
			return m_index<m_collection.length;
		}
	}
}